Skip to content

Conversation

@spilchen
Copy link
Contributor

This is a fix for the schemachanger workload. Previously, columnRemovalWillDropFKBackingIndexes incorrectly identified foreign key dependencies when dropping columns. It included stored columns from indexes, even though only key columns are relevant to determining foreign key dependencies.

This led to false positives where a drop column operation was expected to fail due to a foreign key dependency, even when it wouldn't in practice.

To address this:

  • The function (now renamed to columnDropViolatesFKIndexRequirements) now filters out stored columns, considering only key columns when determining if an index would be invalidated by the column drop.
  • A new logic test was added to model the SQL logic under various scenarios. The test uses a UDF with pg_catalog queries instead of SHOW INDEXES (which cannot be used inside SQL functions), but the behavior is equivalent.

Fixes #157886

Release note: none

This is a fix for the schemachanger workload. Previously,
`columnRemovalWillDropFKBackingIndexes` incorrectly identified foreign key
dependencies when dropping columns. It included stored columns from indexes,
even though only key columns are relevant to determining foreign key
dependencies.

This led to false positives where a drop column operation was expected to
fail due to a foreign key dependency, even when it wouldn't in practice.

To address this:
- The function (now renamed to `columnDropViolatesFKIndexRequirements`) now
  filters out stored columns, considering only key columns when determining
  if an index would be invalidated by the column drop.
- A new logic test was added to model the SQL logic under various scenarios.
  The test uses a UDF with pg_catalog queries instead of `SHOW INDEXES`
  (which cannot be used inside SQL functions), but the behavior is equivalent.

Fixes cockroachdb#157886

Release note: none
@spilchen spilchen self-assigned this Nov 20, 2025
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@spilchen spilchen marked this pull request as ready for review November 20, 2025 14:03
@spilchen spilchen requested a review from a team as a code owner November 20, 2025 14:03
@spilchen spilchen requested review from a team, nameisbhaskar and williamchoe3 and removed request for a team November 20, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

roachtest: schemachange/mixed-versions failed

2 participants